//
//  ProblemView.m
//  ZYShang
//
//  Created by wangguangming on 15/8/4.
//  Copyright © 2015年 Amber. All rights reserved.
//

#import "ProblemView.h"
#import "UIImage+imagedown.h"
#import "Base.h"
#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height
@implementation ProblemView
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
        {
        self.backgroundColor=COLOR;
        [self addall];
        }
    return self;
}
-(void)addall
{
    self.titleLaber=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
    self.titleLaber.text=@"调整库存不足商品的数量";
    self.titleLaber.textColor=[UIColor grayColor];
    [self.titleLaber setAdjustsFontSizeToFitWidth:YES];
    self.titleLaber.textAlignment=NSTextAlignmentCenter;
    [self addSubview:self.titleLaber];
    
    
    self.messageLaber=[[UILabel alloc] initWithFrame:CGRectMake(0, HEIGHT-100, WIDTH, 60)];
    self.messageLaber.text=@"实际库存不足!修改订单商品数量至实际库存数量,线上库存改为0";
    self.messageLaber.numberOfLines=2;
    self.messageLaber.textColor=[UIColor grayColor];
    [self.messageLaber setAdjustsFontSizeToFitWidth:YES];
    self.messageLaber.textAlignment=NSTextAlignmentCenter;
    [self addSubview:self.messageLaber];
    
    NSArray *array=@[@"拒收",@"配好",@"取消"];
    for (int i=0; i<3; i++)
        {
         self.shitButton=[[UIButton alloc] initWithFrame:CGRectMake(WIDTH/10+(WIDTH/5+WIDTH/10)*i, HEIGHT-40, WIDTH/5, 40)];
        
        [self.shitButton setTitle:array[i] forState:UIControlStateNormal];
        self.shitButton.backgroundColor=BLUECOLOL;
        self.shitButton.layer.cornerRadius=4;
        [self.shitButton setTag:110+i];
        [self addSubview:self.shitButton];
        }
    UILabel *l=[[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.titleLaber.frame), WIDTH, 1)];
    l.backgroundColor=[UIColor grayColor];
    [self addSubview:l];
    
    self.itemScroll=[[UIScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.titleLaber.frame)+1, WIDTH, HEIGHT-140)];
    self.itemScroll.backgroundColor=COLOR;
    [self addSubview:self.itemScroll];
   
    
}
-(void)setItemview:(NSMutableArray *)array
 
{
    for (int i=0; i<array.count; i++)
        {
        self.itemsView=[[ItemView alloc] initWithFrame:CGRectMake(1, 0+(WIDTH/5+2)*i, WIDTH, WIDTH/5)];
        Items *items=array[i];
            //NSLog(@"%@",items.pic);
        self.itemsView.titleLaber.text=items.title;
//        self.itemsView.itemImage.image=[UIImage imageDownWithurlstring:items.pic imagebolock:^(UIImage *img) {
//            self.itemsView.itemImage.image=img;
//        }];
        [self.itemsView setImage:items];
        self.itemsView.pieceLaber.text=[NSString stringWithFormat:@"¥:%.2f*%d",items.price.doubleValue,items.quantity.integerValue];
        
        self.itemsView.numberLaber.text=[NSString stringWithFormat:@"%d",items.quantity.integerValue];
        [self.itemScroll addSubview:self.itemsView];
      
        [self.itemsView.suButton setTag:200+i];
        [self.itemsView.addButton setTag:400+i];
        [self.itemsView.numberLaber setTag:300+i];
            //  NSLog(@"%d",self.itemsView.numberLaber.tag);
        }
    self.itemScroll.contentSize=CGSizeMake(0, array.count*(WIDTH/5+2));
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
